<template>
  <div class="sex">
    <div class="title">
      <p>男女比例</p>
      <img src="../../images/dataScreen-title.png" alt="" />
    </div>
    <div class="image_box">
      <div class="man">
        <span>男士</span>
        <div class="image"></div>
      </div>
      <div class="woman">
        <span>女士</span>
        <div class="image"></div>
      </div>
    </div>
    <div class="rate">
      <span class="man_rate">男士60%</span>
      <span class="woman_rate">女士40%</span>
    </div>
    <div class="charts" ref="charts"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
const charts = ref()
onMounted(() => {
  const myecharts = echarts.init(charts.value)
  myecharts.setOption({
    title: {
      text: '男女比例',
      textStyle: {
        color: 'skyblue',
      },
      left: '40%',
    },
    xAxis: {
      show: false,
      min: 0,
      max: 100,
    },
    yAxis: {
      show: false,
      type: 'category',
    },
    series: [
      {
        type: 'bar',
        data: [60],
        barWidth: 20,
        z: 100,
        itemStyle: {
          color: 'skyblue',
          borderRadius: 20,
        },
      },
      {
        type: 'bar',
        data: [100],
        barWidth: 20,
        //调整女士柱条位置
        barGap: '-100%',
        itemStyle: {
          color: 'pink',
          borderRadius: 20,
        },
      },
    ],
    grid: {
      left: 0,
      top: 0,
      right: 0,
      bottom: 0,
    },
  })
})
</script>

<style scoped lang="scss">
.sex {
  margin-top: 20px;
  width: 100%;
  height: 100px;
  background: url(../../images/dataScreen-main-cb.png) no-repeat;
  background-size: 100% 100%;
  .title {
    margin-top: 20px;
    p {
      color: white;
    }
  }
  .image_box {
    display: flex;
    justify-content: center;
    .man {
      margin: 20px 20px;
      width: 111px;
      height: 116px;
      background: url(../../images/man-bg.png);
      span {
        color: white;
        margin-left: 40px;
      }
      .image {
        margin: 20px;
        width: 61px;
        height: 61px;
        background: url(../../images/man.png) no-repeat;
        background-size: 100% 100%;
      }
    }
    .woman {
      margin: 20px 20px;
      width: 111px;
      height: 116px;
      background: url(../../images/woman-bg.png) no-repeat;
      background-size: 100% 100%;
      span {
        // margin-top: 10px;
        color: white;
        margin-left: 40px;
      }
      .image {
        margin: 20px;
        width: 61px;
        height: 61px;
        background: url(../../images/woman.png) no-repeat;
        background-size: 100% 100%;
      }
    }
  }
  .rate {
    padding: 0 50px;
    display: flex;
    // width: 100%;
    // height: 100%;
    color: white;
    justify-content: space-between;
    // background: red;
    span {
      height: 20px;
    }
  }
  .charts {
    height: 100px;
    // background: red;
  }
}
</style>
